package com.yesep.learn.hik.model;

import cn.hutool.json.JSONUtil;
import lombok.Data;

/**
 * @Description: 响应
 */
@Data
public class R {
    private Integer State;
    private String StateMsg;
    private Integer FrameId;
    private String FrameData;

    public static R me(Integer State, String StateMsg) {
        return me(State, StateMsg, 1, "");
    }

    public static R me(Integer State, String StateMsg, Integer FrameId, String FrameData) {
        R r = new R();
        r.setState(State);
        r.setStateMsg(StateMsg);
        r.setFrameId(FrameId);
        r.setFrameData(FrameData);
        return r;
    }

    public String toJson() {
        //String json = String.format("{\"State\":%d,\"StateMsg\":\"%s\",\"FrameId\":%d,\"FrameData\":\"%s\"}", State, StateMsg, FrameId, FrameData);
        String json = JSONUtil.toJsonStr(this);
        return json;
    }
}
